<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title><spring:message code="member.myShoppingCart"></spring:message></title>
    <link href="${pageContext.request.contextPath }/phone/css/font/iconfont.css" rel="stylesheet" type="text/css" />
    <!--公共样式-->
    <link href="${pageContext.request.contextPath }/phone/css/public.css" rel="stylesheet" type="text/css" />
    <!--layer弹出-->
    <link href="${pageContext.request.contextPath }/phone/js/layer/skin/layer.css" rel="stylesheet" type="text/css" />
    <!--我的(个人中心)样式-->
    <link href="${pageContext.request.contextPath }/phone/css/mine.css" rel="stylesheet" type="text/css" />

</head>
<body>
<!--头部 begin-->
<header class="page_topbar">
    <a href="${pageContext.request.contextPath }/api/member/userCenter" class="back Hui-iconfont"></a>
    <div class="title"><spring:message code="member.myShoppingCart"></spring:message></div>
</header>
<!--头部 end-->
<div class="content mb-110">
    <ul class="cartlist">
     <c:forEach items="${list}" var="item">
        <li>
        	<c:choose>
				<c:when test="${item.SC_TYPE==0}">
				 <div class="cartlisttopright"><span><spring:message code="order.printing"></spring:message></span><span>${item.PP_NAME }</span></div>  
				</c:when>
				<c:when test="${item.SC_TYPE==1}">
				  <div class="cartlisttopright"><span><spring:message code="order.buyout"></spring:message></span></div>                          
				</c:when>
				<c:when test="${item.SC_TYPE==2}">
				 <div class="cartlisttopright"><span><spring:message code="order.finishedProduct"></spring:message></span><span>${item.PP_NAME }</span></div>  
				</c:when>
				<c:when test="${item.SC_TYPE==3}">
				  <div class="cartlisttopright"><span><spring:message code="order.fabric"></spring:message></span></div>  
				 </c:when>
			</c:choose> 
            <div class="discuss-list-cont">
                <input class="cartcheck" name="Fruit" type="checkbox" value="${item.SC_ID}" onclick="mani()" mani="${item.SC_TOTAL_PRICE}" />
                 <c:choose>
					<c:when test="${item.SC_TYPE!='3'}">
	                 <a target="_top" href="${pageContext.request.contextPath}/api/pattern/viewpattern?pNo=${item.SC_PATTERN_NO}">
	                  <span class="discuss-list-cont-l"><img src="${item.SC_PATTERN_IMG}" ></span>
	                 </a>
	                </c:when>
	                <c:when test="${item.SC_TYPE=='3'}">
	                <a target="_top" href="${pageContext.request.contextPath}/api/pattern/viewf?fNo=${item.SC_FABRIC_NO}">
	                 <span class="discuss-list-cont-l"><img src="${pageContext.request.contextPath }/upload/${item.SC_FABRIC_COLOR}" ></span>
	                </a>
	             </c:when>
	             </c:choose>
                <span class="discuss-list-cont-r discart">
                 <c:choose>
					<c:when test="${item.SC_TYPE==0}">
					<p><span class="dis-title"><spring:message code="pattern"></spring:message>：${item.SC_PATTERN_NO}</span><span class="dis-time">X${item.SC_FABRIC_SIZE}</span></p>
                    <p><span class="dis-title">￥${item.SC_PATTERN_SINGLE_PRICE }</span><span class="dis-time Hui-iconfont" onclick="deletes(${item.SC_ID});">&#xe609;</span></p>
					</c:when>
					<c:when test="${item.SC_TYPE==1}">
					<p><span class="dis-title"><spring:message code="pattern"></spring:message>：${item.SC_PATTERN_NO}</span><span class="dis-time">X${item.SC_FABRIC_SIZE}</span></p>
                    <p><span class="dis-title">￥${item.SC_PATTERN_SINGLE_PRICE }</span><span class="dis-time Hui-iconfont" onclick="deletes(${item.SC_ID});">&#xe609;</span></p>
					</c:when>
					<c:when test="${item.SC_TYPE==2}">
					<p><span class="dis-title"><spring:message code="pattern"></spring:message>：${item.SC_PATTERN_NO}</span><span class="dis-time">X${item.SC_FABRIC_SIZE}</span></p>
                    <p class="discuss-list-cont-detail"><spring:message code="order.fabric"></spring:message>：${item.SC_FABRIC_NO}</p>
                    <p><span class="dis-title">￥${item.SC_PATTERN_SINGLE_PRICE }</span><span class="dis-time Hui-iconfont" onclick="deletes(${item.SC_ID});">&#xe609;</span></p>
					</c:when>
					<c:when test="${item.SC_TYPE==3}">
					<p><span class="dis-title"><spring:message code="order.fabric"></spring:message>：${item.SC_FABRIC_NO}</span><span class="dis-time">X${item.SC_FABRIC_SIZE}</span></p>
                    <p><span class="dis-title">￥${item.SC_PATTERN_SINGLE_PRICE }</span><span class="dis-time Hui-iconfont" onclick="deletes(${item.SC_ID});">&#xe609;</span></p>
					</c:when>
				</c:choose> 
                </span>
            </div>
            <div class="cartlistdollor"><span><spring:message code="jinee"></spring:message>：￥${item.SC_TOTAL_PRICE }</span></div>
        </li>
      </c:forEach>
    </ul>

</div>
<div class="bottomcart">
    <div class="cartlistdollor"><span><spring:message code="heji"></spring:message>：￥<span id="mani">0</span></span></div>
    <div class="block-auto"><a class="end-next" href="JavaScript:ordergenerated()"><spring:message code="qujiesuan"></spring:message></a></div>
</div>

<form id="mai"  target="_top"   action="${pageContext.request.contextPath }/api/orders/caraccount" method="post">
 <input type="hidden" name="oId" id="oId">
</form>
</body>
<script src="${pageContext.request.contextPath }/phone/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/layer_mobile/layer.js"></script>
<script>

function mani() {
	var count = 0;
	$("input[type=checkbox]").each(function(){
		if($(this).attr("checked") == "checked"){
			count = $(this).attr("mani")-0+count;
		}
	});
	$("#mani").text(count.toFixed(2));
}
    function deletes(id){
    	   layer.open({
			    content: '<spring:message code="reciveAddress.confirmDeletion"></spring:message>'
			    ,btn: ['<spring:message code="reciveAddress.confirm"></spring:message>', '<spring:message code="reciveAddress.cancel"></spring:message>']
			    ,yes: function(index){
			    	$.ajax({
		       	   		 url:'${pageContext.request.contextPath }/web/shoppingcart/delshoppingcart',
		       	   		 async : false,
		       	   		 data: {scId:id},
		       	   		 type : "POST", 
		       	   		 success :function(result){
		       	   		 var status=result.msg.status;
		       	   		 var desc=result.msg.desc;
		       	   		 if(status == 0){
		       	   		layer.open({content: '<spring:message code="caozuochenggong"></spring:message>',skin: 'msg',time: 1});
		       	   			 location.reload(true);
		       	   		 }else if(status == 2){//没登录
		       	   		layer.open({content: '<spring:message code="weidenglu"></spring:message>',skin: 'msg',time: 1});
		       	   		    }else if(status ==1){//失败
		       	   		  layer.open({content: '<spring:message code="caozuoshibai"></spring:message>',skin: 'msg',time: 1});
		       	   		    }
		       	   		 }
		       	   		 });
			    }
			  });
    	
    }
    
function ordergenerated(){
    	
    	var searchVals=[];
    	$("input[type=checkbox]").each(function(){
    		if($(this).attr("checked") == "checked"){
    			searchVals.push($(this).val());
    		}
    	});
    	if(searchVals.length==0){
    		layer.open({content: '<spring:message code="reciveAddress.choose"></spring:message>',skin: 'msg',time: 1});
   	   		
    		 return;
    	}
    	$.ajax({
      		 url:'${pageContext.request.contextPath }/web/orders/look',
      		 async : false,
      		 traditional:true,
      		 data: {"oId":searchVals},
      		 type : "POST", 
      		 success :function(result){
      		 var status=result.msg.status;
      		 var desc=result.msg.desc;
      		 if(status == 0){
      			 $("#oId").val(searchVals);
      			 $("#mai").submit();
      		 }else if(status ==1){//失败
      			layer.open({content: '<spring:message code="huaxingyibeimaiduan"></spring:message>',skin: 'msg',time: 1});
       	   		
      		    }
      		 }
      		 });
    }
</script>
</html>